<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>$cacheFactory</title>
    <link rel="stylesheet" href="../../lib/bootstrap3/css/bootstrap.min.css">
    <script src="../../lib/angularjs/angular.js"></script>
</head>
<body ng-app="cacheApp">
    <div class="well">
        <h2>默认的$http缓存</h2>
        $http({<br/>
        &nbsp;&nbsp;&nbsp;&nbsp;method: 'GET',<br/>
        &nbsp;&nbsp;&nbsp;&nbsp;url: '/api/users.json',<br/>
        &nbsp;&nbsp;&nbsp;&nbsp;cache: true<br/>
        });<br/>
        // 或者使用辅助方法.get()<br/>
        $http.get('/api/user.json', {<br/>
        &nbsp;&nbsp;&nbsp;&nbsp;cache: true<br/>
        });<br/>
    </div>
    <div class="well" ng-controller="ctrl01">
        <h2>清除缓存</h2>
        var cache = $cacheFactory('$http');<br/>
        // 获取上一次请求的缓存<br/>
        var usersCache = cache.get('http://example.com/api.users.json');<br/>
        // 删除上一次请求的缓存入口<br/>
        cache.remove('http://example.com/api.users.json');<br/>
        // 重新开始并移除全部缓存<br/>
        cache.removeAll();<br/>
    </div>
    <div class="well">
        <h2>28.3.2 自定义缓存</h2>
        var myCache = $cacheFactory('myCache');<br/>
        $http({<br/>
        method: 'GET',<br/>
        utl: '/api/users.json',<br/>
        cache: myCache<br/>
        });<br/>
        // 或者使用辅助方法.get()<br/>
        $http.get('/api/users.json', {<br/>
        cache: myCahe<br/>
        });<br/>
    </div>
<div class="well">
    <h2>28.4 为$http 设置默认缓存</h2>
    对每个请求使用同一缓存
    <xmp>
angular.module('myApp', []).config(function($httpProvider) {
    $httpProvider.defaults.cache = $cacheFactory('myCache', {capacity: 20});
});
    </xmp>
</div>
</body>
<script>
    var app=angular.module("cacheApp",[]);

</script>
</html>